Memory allocations in computer systems can typically be classified as either static allocations or dynamic allocations. Generally, the size and lifetime of statically allocated memory may be known before runtime (e.g., expressly defined in source code). Conversely, the size and lifetime of dynamically allocated objects in memory (e.g., in a “heap” portion of the memory) may vary during runtime. The process of monitoring dynamic memory operations may be referred to as memory management. Memory management may help prevent undesirable situations such as memory leaks in which memory space that is dynamically allocated by an application is not deallocated, thereby becoming “lost” to the application.
Garbage collectors are memory management tools that can deallocate dynamically allocated memory. When dynamically allocated objects in a managed heap are independent of objects outside the scope of the managed heap, garbage collectors may provide relatively stable and reliable memory management. However, dynamically allocated objects may include or refer to objects that are outside the scope of the managed heap (e.g., native objects), and vice versa. In this scenario, the garbage collector may not be able to deallocate managed objects from the managed heap until one or more associated native objects have been collected.